import { getOperateTypeEnumSchema } from '@/enums/operateTypeEnum';
import { AdColumn } from '@/components/AdVxeTable';
import { useI18n } from '@/hooks/web/useI18n';

const { t } = useI18n();
const operateTypeEnumSchema = getOperateTypeEnumSchema();

export const auditEntityColumns: AdColumn[] = [
  {
    title: t('routes.system.audit.auditEntityIdTitle'),
    field: 'Id',
    width: 0,
    visible: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('routes.system.audit.auditEntityNameTitle'),
    field: 'Name',
    width: 200,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityTypeNameTitle'),
    field: 'TypeName',
    // width: 200,
    minWidth: 200,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityEntityKeyTitle'),
    field: 'EntityKey',
    width: 150,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityOperateTypeTitle'),
    field: 'OperateType',
    width: 100,
    filterable: true,
    dataType: 'enum',
    enumData: operateTypeEnumSchema,
  },
  {
    title: t('routes.system.audit.auditEntityUserIdTitle'),
    field: 'UserId',
    width: 0,
    visible: false,
    filterable: true,
    filterIndex: 'Operation.UserId',
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityUserNameTitle'),
    field: 'UserName',
    width: 120,
    filterable: true,
    filterIndex: 'Operation.UserId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityUserNicknameTitle'),
    field: 'UserNickname',
    width: 150,
    filterable: true,
    filterIndex: 'Operation.UserId',
    filterJoin: {
      entityType: 'MicroCloud.Pack.Identity.Entities.User,MicroCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityFunctionNameTitle'),
    field: 'FunctionName',
    width: 200,
    filterable: true,
    filterIndex: 'Operation.FunctionName',
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityCreatedTimeTitle'),
    field: 'CreatedTime',
    width: 150,
    filterable: true,
    filterIndex: 'Operation.CreatedTime',
    dataType: 'datetime',
  },
];

export const auditPropertyColumns: AdColumn[] = [
  {
    title: t('routes.system.audit.auditEntityPropertieDisplayNameTitle'),
    field: 'DisplayName',
    width: 150,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityPropertieFieldNameTitle'),
    field: 'FieldName',
    width: 150,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityPropertieOriginalValueTitle'),
    field: 'OriginalValue',
    width: 200,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityPropertieNewValueTitle'),
    field: 'NewValue',
    width: 200,
    dataType: 'string',
  },
  {
    title: t('routes.system.audit.auditEntityPropertieDataTypeTitle'),
    field: 'DataType',
    width: 200,
    dataType: 'string',
  },
];
